# -*- coding: utf-8 -*-

import ctypes
import string
import os
from datetime import datetime


# 检测盘符余量函数
def get_free_space(path):
	free_bytes = ctypes.c_ulonglong(0)
	ctypes.windll.kernel32.GetDiskFreeSpaceExW(ctypes.c_wchar_p(path), None, None, ctypes.pointer(free_bytes))
	return free_bytes


# 遍历盘符
available_drives = ['%s:' % d for d in reversed(string.ascii_uppercase) if os.path.exists('%s:' % d)]

# 自定义帧率
fps = 13.42

# 如果余量满足则创建tiff保存路径和fps.txt文件
for drive in available_drives:
	space = get_free_space(drive).value
	if space >= 0:
		save_dir = drive
		now = datetime.now()
		name = now.strftime("%Y-%m-%d %H-%M-%S")
		save_raw = f'{save_dir}/{name}.tiff'
		with open(f"{save_dir}/{name}.txt", 'w') as f:
			f.write(f'fps:{fps}')
		break
